package com.itheima.service.serviceimpl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.dao.OrderDao;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDao orderDao;

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {

        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Order> p = orderDao.findPage(queryPageBean);
        return new PageResult(p.getTotal(),p.getResult());

    }

    @Override
    public void update(Order order) {
        orderDao.update(order);
    }
}
